#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int a[100005]; 
int main(){
	a[0]=2000000000;
	int n,m;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	cin>>m;
	for(int i=1;i<=m;i++){
		int x;
		cin>>x;
	
		int l=1,r=n;
		while(l+1<r){
			int mid=(l+r)/2;
			if(a[mid]==x){
				l=r=mid;
			}else if(a[mid]>x){
				r=mid;
			}else{
				l=mid;
			}
		}
		if(l==r) cout<<a[l]<<endl;
		else if(x-a[l]<=a[r]-x) cout<<a[l]<<endl;
		else cout<<a[r]<<endl;
	
	}
	return 0;
}
